アクティビティ
最新
生産性を高めるアクティビティ
Last updated 2024年7月1日

Google ドライブ API

Google ドライブ サービスを作成します。

名前空間: UiPath.Gsuite.Activities.API

アセンブリ: UiPath.Gsuite.Activities.API (UiPath.Gsuite.Activities.API.dll 内)

コンストラクター

コンストラクター説明構文
GoogleDriveServiceGoogleDriveService クラスの新しいインスタンスを初期化します。
public class GoogleDriveService : IGoogleDriveServicepublic class GoogleDriveService : IGoogleDriveService

メソッド

名前説明
ファイル ラベルを適用指定したファイルに Google ドライブのラベルを適用します。
ファイル ラベルのフィールドをクリアファイルから 1 つ以上のラベル フィールドを削除します。
ファイルをコピー指定した Google ドライブの場所にあるファイルをコピーします。
フォルダーを作成指定した Google ドライブの場所にあるフォルダーをコピーします。
アイテムを削除指定したファイルまたはフォルダーを削除します。
ファイルをダウンロード指定したファイルをダウンロードします。
ドライブ ラベルを取得空のフィールドを持つドライブのラベルを取得します。
GetFileGoogle ドライブから、相対パス、URL、ID、またはフル パスでファイルを取得します。
ファイル ラベルを取得指定した Google ドライブの場所からファイルのリストを取得します。
ファイルを取得指定した Google ドライブの場所からファイルのリストを取得します。
GetFilesandFolders指定した Google ドライブの場所からファイルとフォルダーのリストを取得します。
フォルダーを取得

Google ドライブから、相対パス、URL、ID、またはフル パスでフォルダーを取得します。

フォルダーを取得指定した Google ドライブの場所からフォルダーのリストを取得します。
アイテムを取得

Google ドライブから、相対パス、URL、ID、またはフル パスでフォルダーまたはフォルダーを取得します。

ファイルを移動Google ドライブ内の指定した移動先フォルダーにフォルダーを移動します。
フォルダーを移動Google ドライブ内の指定した移動先フォルダーにフォルダーを移動します。
RefreshFile指定したファイルの最新バージョンを取得します。
RefreshFolder指定したフォルダーの最新バージョンを取得します。
RefreshItem指定したファイルまたはフォルダ―の最新バージョンを取得します。
ファイル ラベルを削除ファイルからラベルを削除します。
ファイルを共有

任意のユーザー、ドメイン、または指定した受信者とファイルを共有します。

フォルダーを共有

任意のユーザー、ドメイン、または指定した受信者とフォルダーを共有します。

ファイルをアップロードファイルを Google ドライブにアップロードします。
ファイルをアップロードファイルを Google ドライブにアップロードします。

次の例では、API を使用して、Google ドライブのフォルダーにあるすべてのファイルにプレフィックスを追加してファイルの名前を変更する方法を確認できます。
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class Rename_all_the_files_in_a_Google_Drive_folder : CodedWorkflow
    {
        [Workflow]
        public void Execute(string NameSubfix)
        {
           var service = google.Drive(connections.Drive.<connectionID>);
            
            var folderUrl ="https://drive.google.com/drive/folders/1sE7UqjderUPv24Rxkto5jyefAuVLeVCz";
            var folder = service.GetFolder(folderUrl,IdentificationType.UrlOrId);
            var files = service.GetFiles(folder);
            foreach (var file in files)
            {
                System.Console.WriteLine(file.FullName);
                file.Move(folder,file.FullName+"-"+NameSubfix,ConflictBehavior.Replace);
                
            }
        }
    }
}
次の例では、API を使用して、サブフォルダーを含むフォルダー内のすべてのファイルを読み取る方法を確認できます。
using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}using GoogleWorkspaceCodedWorkflows.ObjectRepository;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using UiPath.CodedWorkflows;
using UiPath.Core;
using UiPath.Core.Activities.Storage;
using UiPath.Excel;
using UiPath.Excel.Activities;
using UiPath.Excel.Activities.API;
using UiPath.Excel.Activities.API.Models;
using UiPath.GSuite.Activities.Api;
using UiPath.GSuite.Drive.Models;
using UiPath.Mail.Activities.Api;
using UiPath.Orchestrator.Client.Models;
using UiPath.Testing;
using UiPath.Testing.Activities.TestData;
using UiPath.Testing.Activities.TestDataQueues.Enums;
using UiPath.Testing.Enums;
using UiPath.UIAutomationNext.API.Contracts;
using UiPath.UIAutomationNext.API.Models;
using UiPath.UIAutomationNext.Enums;

namespace GoogleWorkspaceCodedWorkflows
{
    public class ReadAllFilesFromAFolder : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {            
            var service = google.Drive(connections.Drive.<connectionID>);     
         
            // Read All files from Google Drive and its subfolders 
            readFilesInAFolder(null,service);
            
        }
        // Read All files from a Folder including all subfolders
        public void readFilesInAFolder(IFolder? googleFolder, IGoogleDriveService service)
        {
            var filesAndFolders = service.GetFilesAndFolders(googleFolder);
        
            foreach (var fileFolder in filesAndFolders.OrderBy(f=> f.IsFolder))
            {
                if(!fileFolder.IsFolder)
                {
                    var folder = service.GetFolder(fileFolder.Item.ParentId);
                    
                    Log("Folder: "+ folder.FullName+" FileName: "+fileFolder.FullName+ " Type: "+fileFolder.Item.MimeType);
                }
                else
                {
                    readFilesInAFolder(fileFolder as IFolder, service);
                }
            }
            
        }
    }
    
}
  • コンストラクター
  • メソッド

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.